﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="/favicon.ico">
	<link rel="Shortcut Icon" href="/favicon.ico" />
	<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
	<!--/meta 作为公共模版分离出去-->

	<title>推流地址获取</title>
</head>

<body>
	<div class="page-container">
		<div class="form form-horizontal" id="form-article-add">

			<input type="hidden" name="token" value="<%=token%>">
			<div id="tab-system" class="HuiTab">
				<div class="tabBar cl">
					<span>地址申请</span>
					<span>历史地址</span>
					<span>修改密码</span>
				</div>
				<div class="tabCon">
					<div class="row cl">
						<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
							<button id="btn_apply" class="btn btn-primary radius" type="button">
								<i class="Hui-iconfont"></i>一键获取地址</button>
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">直播标题：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="" id="title" name="" placeholder="建议填写直播标题">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">发布地址：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="" id="pushrtmp" name="">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">流名：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" id="streamid" value="" class="input-text">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">HLS播放地址：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="" id="hls" name="">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">RTMP播放地址：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="" id="rtmp" name="">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">点播地址(MP4)：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" id="replaymp4" value="" class="input-text">
						</div>
					</div>
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">点播地址(M3U8)：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" id="replaym3u8" value="" class="input-text">
						</div>
					</div>
				</div>
				<div class="tabCon">
					<div class="cl pd-5 bg-1 bk-gray mt-20">
						<span class="l">
							<span class="r">共有数据：
								<strong>
									<%=history.length%>
								</strong> 条</span>
					</div>
					<table class="table table-border table-bordered table-bg">
						<thead>
							<tr>
								<th scope="col" colspan="11">直播列表</th>
							</tr>
							<tr class="text-c">
								<th width="30">编号</th>
								<th width="70">直播ID</th>
								<th width="210">标题</th>
								<th width="50">创建时间</th>
								<th width="30">rtmp发布地址</th>
								<th width="100">流名</th>
								<th width="100">rtmp拉流地址</th>
								<th width="85">HLS播放地址</th>

								<th width="40">点播地址(mp4)</th>
								<th width="40">点播地址(m3u8)</th>
								<th width="20">操作</th>
							</tr>
						</thead>
						<tbody>
							<% for(var i=0;i<history.length;i++){%>
								<tr class="text-c" style="<%=history[i].isupdated==1?'background:#d1e6d1':'background:white'%>">
									<td>
										<%=history[i].id%>
									</td>
									<td>
										<%=history[i].liveid%>
									</td>
									<td>
										【<%=new Date(history[i].createdate).toLocaleString()%>】<br/><%=history[i].title%>
									</td>
									<td>
										<%=new Date(history[i].createdate).toLocaleString()%>
									</td>
									<td>
										<%=history[i].rtmp%>
									</td>
									<td>
										<%=history[i].streamid%>
									</td>
									<td>
										<%=history[i].hls.replace('https://c-hls','rtmp://c-live').replace('.m3u8','')%>
									</td>
									<td>
										<%=history[i].hls%>
									</td>
									<td>
										<%=history[i].replaymp4%>
									</td>
									<td>
										<%=history[i].replaym3u8%>
									</td>
									<td class="td-manage">
										<a style="text-decoration:none" class="ml-5" onClick="reseturl('<%=history[i].liveid%>')" href="javascript:;" title="获取最新地址">
											<i class="Hui-iconfont"></i>
										</a>
									</td>
								</tr>
								<%}%>
						</tbody>
					</table>
					<div id="page1"></div>
				</div>
				<div class="tabCon">
					<form class="form form-horizontal" id="form-admin-add">
						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-3">
								<span class="c-red">*</span>新密码：</label>
							<div class="formControls col-xs-8 col-sm-9">
								<input type="text" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
							</div>
						</div>

						<div class="row cl">
							<label class="form-label col-xs-4 col-sm-3">
								<span class="c-red">*</span>确认密码：</label>
							<div class="formControls col-xs-8 col-sm-9">
								<input type="text" class="input-text" autocomplete="off" placeholder="确认新密码" id="password2" name="password2">
							</div>
						</div>


						<div class="row cl">
							<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
								<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
							</div>
						</div>

					</form>
				</div>
			</div>
		</div>

	</div>
	</div>

	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
	<!--/_footer 作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript" src="lib/jquery.cookie.js"></script>
	<script type="text/javascript" src="lib/jquery.query-2.1.7.js"></script>

	<script type="text/javascript">
		/*密码-修改*/
		function reseturl(liveid) {
			layer.confirm('确认获取最新地址？', function (index) {
				$.ajax({
					type: 'POST',
					url: '/reseturl',
					data: { liveid: liveid, token: "<%=token%>" },
					dataType: 'json',
					success: function (data) {
						if(data.success){
							location.reload();
						}if(data.value.code==7010){
							layer.msg('此直播还未开播', { icon: 4, time: 5000 });
						}
					},
					error: function (data) {
						console.log(data.msg);
					},
				});
			});
		}

		$(function () {
			$("#tab-system").Huitab({
				index: 1
			});

			$("#form-admin-add").validate({
				rules: {
					password: {
						required: true,
					},
					password2: {
						required: true,
						equalTo: "#password"
					}
				},
				onkeyup: false,
				focusCleanup: true,
				success: "valid",
				submitHandler: function (form) {
					$.ajax({
						type: 'POST',
						url: '/users/changepassword',
						dataType: 'json',
						data: {
							uid: "<%=id%>",
							password: form['password'].value
						},
						success: function (data) {
							layer.msg('密码修改成功!', { icon: 1, time: 2000 });
							location.replace(location.href);
						},
						error: function (data) {
							console.log(data.msg);
							layer.msg('密码修改失败!', { icon: 5, time: 2000 });

						},
					});
				}
			});


			$('#btn_apply').click(function () {
				var token = "<%=token%>";
				//alert(token);
				if (token == '') {
					location.href = '/login';
				}
				else if ($('#title').val().trim().length == 0) {
					//alert('请填写直播标题');
					layer.msg('请填写直播标题!', { icon: 2, time: 3000 });
				}
				else {
					$.ajax({
						type: 'POST',
						url: '/apply',
						dataType: 'json',
						data: {
							token: "<%=token%>",
							title: $('#title').val(),
							id: "<%=id%>"
						},
						success: function (data) {
							console.log(data);

							var s = data.pushurl;
							//获取liveid
							var liveid = data.liveid;
							var rtmp_header = s.substring(0, s.lastIndexOf('/'));//rtmp://c-push.sioeye.cn/sioeyecn
							var streamid = s.substring(s.lastIndexOf('/') + 1, s.lastIndexOf('-'));//JjuQfq
							$('#pushrtmp').val(rtmp_header);

							var stream = s.substring(s.lastIndexOf('/') + 1, s.length);
							$('#streamid').val(stream);

							$('#hls').val('https://c-hls.sioeye.cn/sioeyecn/' + streamid + '.m3u8');
							$('#rtmp').val('rtmp://c-live.sioeye.cn/sioeyecn/' + streamid);

							var nowDate = new Date();
							var year = nowDate.getFullYear();
							var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
								: nowDate.getMonth() + 1;
							var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
								.getDate();
							var dateStr = year + "-" + month + "-" + day;

							$('#replaymp4').val('https://k-replay.sioeye.cn/' + dateStr + '/' + liveid + '/' + liveid + '.mp4');
							$('#replaym3u8').val('https://k-replay.sioeye.cn/' + dateStr + '/' + liveid + '/' + liveid + '.m3u8');
						},
						error: function (data) {
							console.log(data.msg);
						}
					});
				}
			});
		});


	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>

</html>